<?php

abstract class Ext_Db_Table extends Zend_Db_Table
{
    protected static $_instance = array();
    
    protected $_dbprefix;
    
    public function __construct()
    {
        $_use_adapter = Zend_Registry::get('_use_adapter');
        $this->_dbprefix = Zend_Registry::get('dbprefix');

        if(isset($_use_adapter)){
            $config = Zend_Registry::get('dataSource')->getConnection($_use_adapter);
            
            $this->_name = $this->_dbprefix.$this->_name;

            parent::__construct($config);
        }        
    }
    
    public static function getInstance()
    {
        $_className = _get_called_class();
        if (!isset(self::$_instance[$_className])) {
            self::$_instance[$_className] = new $_className();
        }

        return self::$_instance[$_className];
    }
}

